#ifndef _GIMBAL_H_
#define _GIMBAL_H_
#include "headfile.h"

#define GIMBAL_PORT     					GPIOA
#define GIMABL_YAW_DIR_PIN  			DL_GPIO_PIN_7
#define GIMABL_PIT_DIR_PIN  			DL_GPIO_PIN_23

#define GIMABL_YAW_PWM_PIN  			DL_GPIO_PIN_27
#define GIMABL_PIT_PWM_PIN  			DL_GPIO_PIN_14

#define GIMBAL_YAW_DIR(x)  gpio_set(GIMBAL_PORT, GIMABL_YAW_DIR_PIN, x)
#define GIMBAL_PIT_DIR(x)  gpio_set(GIMBAL_PORT, GIMABL_PIT_DIR_PIN, x)

#define GIMBAL_YAW_DIR_READ  		gpio_get(GIMBAL_PORT, GIMABL_YAW_DIR_PIN)
#define GIMBAL_PIT_DIR_READ  		gpio_get(GIMBAL_PORT, GIMABL_PIT_DIR_PIN)

typedef struct POINTS
{
	uint16_t x;
	uint16_t y;
}Point_t;
typedef struct RECTANGLE
{
	Point_t Outer_Rect[4];
	Point_t Inter_Rect[4];
	Point_t Target_Rect[4];
}RectAngle;
typedef struct LASER
{
	Point_t Green_Laser;
	Point_t Red_Laser;
	Point_t Purple_Laser;
}Laser_t;
typedef struct STEEPMOTER
{
		uint32_t total_steps;
    volatile uint32_t step_count;
	
		float step_angle;
    uint32_t micro_step ;
		bool running;
	
		float current_angle;
}Steep_Moter_t;
typedef struct {
		float target_yaw;
		float target_pitch; 
} Gimbal_t;
typedef struct GIMBAL
{
	Steep_Moter_t Pitch;
	Steep_Moter_t Yaw;
}Gimbal;
extern Point_t point;
extern Laser_t laser;
extern Gimbal gimbal;
extern Gimbal_t gimbal_data;
extern RectAngle rect;
void gimbal_control_absolute(float target_yaw, float target_pitch);
void gimbal_init(Gimbal *gimbal);
void gimbal_control(float yaw_angle, float pitch_angle);
void parse_rect_data(const char *data);
void OLDE_Show_Rect_Data();
#endif